<?php

namespace app\controllers;

use app\controllers\action\Teacher;
use core\controller\Controller;
use db\Conn;

class operate_verify implements Controller
{
    public static function execute()
    {
        $return = ["code" => 400, "data" => [], "msg" => "操作失败"];
        $conn = Conn::execute();
        if ($_SESSION["user_type"] == "teacher") {
            if (isset($_POST["action"]) && $_POST["action"] == "1") {
                if(Teacher::agree_verify($conn, $_POST["user_id"])) {
                    $return["code"] = 200;
                    $return["msg"] = "同意成功";
                }
            } else if (isset($_POST["action"]) && $_POST["action"] == "0") {
                if(Teacher::degree_verify($conn, $_POST["user_id"])) {
                    $return["code"] = 200;
                    $return["msg"] = "拒绝成功";
                }
            }
        }

        $conn->close();

        return $return;
    }
}